unit ScanMacUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TfrmScanMac = class(TForm)
    Timer: TTimer;
    Label1: TLabel;
    lblView: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure TimerTimer(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    FAbort: Boolean;
  public
    { Public declarations }
    SLIp, SLMac: TStrings;
    procedure ScanMac;
  end;

var
  frmScanMac: TfrmScanMac;

implementation

uses FunctionUnit;

{$R *.dfm}

procedure TfrmScanMac.FormCreate(Sender: TObject);
begin
  Fabort := False;
  SLIp := TStringList.Create;
  SLMac := TStringList.Create;
end;

procedure TfrmScanMac.FormDestroy(Sender: TObject);
begin
  SLIp.Free;
  SLMac.Free;
end;

procedure TfrmScanMac.ScanMac;
var
  i: Integer;
begin
  for i := 0 to SLIp.Count - 1 do
  begin
    if FAbort then
      Break;
    lblView.Caption := Format('Scanning%d/%d IP', [i + 1, SLIp.Count]);
    Application.ProcessMessages;
    SLMac.Add(GetMac(SLIp[i]));
    Sleep(100);
  end;
  Close;
end;

procedure TfrmScanMac.TimerTimer(Sender: TObject);
begin
  Timer.Enabled := False;
  ScanMac;   
end;

procedure TfrmScanMac.FormShow(Sender: TObject);
begin
  Timer.Enabled := True;
end;

end.
